package {
	import Classes.CLoader;
	import Classes.pj_styles;
	
	import UIFree.controls.uif_popupMenu;
	import UIFree.uif_ecomponent;
	import UIFree.uif_styles;
	
	import api_servers.pi_myserver;
	import api_servers.pi_servers;
	
	import classes.pjf_mailManager;
	
	import dialogs.timeAlerts.pi_alertTime;
	
	import flash.events.Event;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	import flash.system.Security;
	
	import mailru.MailruCall;
	
	import manager.pi_manager;
	
//	[SWF(width="700", height="880", backgroundColor="#FFFFFF")]
	public class pj_mail extends mail_pj {
		public function pj_mail() {
//			stage.displayState 			= StageDisplayState.FULL_SCREEN;
			photo_inject.APPWIDTH 		= stage.stageWidth;
			photo_inject.APPHEIGHT		= stage.stageHeight;
			photo_inject.TOP			= 0;
			pi_myserver.MODEL_NAME 		= 'pjf_m6';
			pi_alertTime._subAccount 	= 989616825;
			super();
		}
		
		override protected function getStyles(): uif_styles {
			return new pj_styles();
		}
		
		override protected function serversInit(): void {
			//var storageURL: String = 'http://storage-27811-3.cs.clodoserver.ru/';
			var storageURL: String = 'http://vds-14a5.1gb.ru/';
			Security.loadPolicyFile(storageURL + CLoader.CROSSDOMAINXML);
			
 			pi_servers.ADDR = ['http://oformi-foto.ru', 'http://oformi-foto.ru', 'http://oformi-foto.ru', 'http://oformi-foto.ru']			
			pi_servers.USERPHOTOHOST	= pi_servers.ADDR[1];
			pi_servers.UPLOADJPG_URL	= pi_servers.ADDR[1] + '/games/index_pj.php';
			
			pi_servers.EFFECTS_URL		= pi_servers.ADDR[3] + '/pj/plugins/filters/';
//			pi_servers.MROOT_URL		= pi_servers.ADDR[3] + '/games/data/a/templates/';
			pi_servers.MROOT_URL		= storageURL + 'pj/';
			pi_servers.PREVIEW_URL		= pi_servers.MROOT_URL + 'jpg_preview/';
			pi_servers.PLUGINS_URL		= pi_servers.ADDR[3] + '/pj/plugins/v02/mail/';
			pi_servers.IMAGESURL		= pi_servers.ADDR[3] + '/pj/images/';
			pi_servers.FLASH_URL		= getHost() + '/templates';
			
			
		}
		
		override protected function createBanners(level: int): void {
		}
		
		override public function getClasses(): Object {
			var lc: Object = super.getClasses();
			lc.alertTime = pi_alertTime;
			lc.popupMenu = uif_popupMenu;
			return lc;
		}
		
		override protected function createSiteData(): Object {
			var obj: Object = super.createSiteData();
			obj.ad.ref_id = '451859761';
			obj.ad.asMail = false;
			return obj;
		}
		
		override public function get balanceMenu(): Array {
			return [
			];
		} 
		
		override protected function mailruReadyHandler(e: Event=null): void {
			_MailruCallActive = true;
			MailruCall.removeEventListener(Event.COMPLETE, mailruReadyHandler);
			
			if (!checkVersion()) alert(pi_data.WARNING, pi_data.LOWFLASHPLAYER, initialize);
			else initialize(externalserver.vars);
		}
		
		override public function payDialog(params: Object, postPayFunc: Function = null): void {
			alert(this['classes'].data.WARNING, 'Вы желаете пополнить счет в приложении при помощи СМС сообщения?', function(): void {
				navigateToURL(new URLRequest('http://oformi-foto.ru/?task=addBalance&price=' + params.price), '_self');
			}, true);
		}
		
		override protected function createManager():pi_manager {
			return new pjf_mailManager(this);
		}
	}
}